﻿Imports Microsoft.VisualBasic

Public Class scrumrBL

	Dim _dal As New ScrumrData

	Public Sub FillProjectList(ByVal ddlProjects As DropDownList)

		ddlProjects.DataSource = _dal.GetProjectList
		ddlProjects.DataTextField = "projectName"
		ddlProjects.DataValueField = "projectId"
		ddlProjects.DataBind()

		ddlProjects.Items.Insert(0, New ListItem("Choose a project...", "0"))

    End Sub

    Public Sub FillProjectListForSMUserID(ByVal ddlProjects As DropDownList, ByVal userID As String)

        ddlProjects.Items.Clear()

        ddlProjects.DataSource = _dal.GetProjectListForSMUserID(userID)
        ddlProjects.DataTextField = "projectName"
        ddlProjects.DataValueField = "projectId"
        ddlProjects.DataBind()

        ddlProjects.Items.Insert(0, New ListItem("Choose a project...", "0"))

    End Sub

    Public Sub FillPrioritiesList(ByVal ddlPriorities As DropDownList)

        ddlPriorities.DataSource = _dal.GetPrioritiesList
        ddlPriorities.DataTextField = "priorityDesc"
        ddlPriorities.DataValueField = "priorityID"
        ddlPriorities.DataBind()

        ddlPriorities.Items.Insert(0, New ListItem("Choose a priority...", "0"))

    End Sub

    Public Sub FillFeaturesList(ByVal ddlFeatures As DropDownList, ByVal sProjectID As String)

        ddlFeatures.Items.Clear()

        ddlFeatures.DataSource = _dal.GetFeaturesList(sProjectID)
        ddlFeatures.DataTextField = "featureName"
        ddlFeatures.DataValueField = "featureID"
        ddlFeatures.DataBind()

        ddlFeatures.Items.Insert(0, New ListItem("Choose a feature...", "0"))

    End Sub

    Public Sub FillFeaturesListBox(ByVal lbFeatures As ListBox, ByVal iProjectID As Integer)

        lbFeatures.Items.Clear()

        lbFeatures.DataSource = _dal.GetFeaturesList(iProjectID)
        lbFeatures.DataTextField = "featureName"
        lbFeatures.DataValueField = "featureID"
        lbFeatures.DataBind()

    End Sub

    Public Sub FillScrumMastersList(ByVal ddlScrumMasters As DropDownList)

        ddlScrumMasters.Items.Clear()

        ddlScrumMasters.DataSource = _dal.GetScrumMastersList
        ddlScrumMasters.DataTextField = "UserName"
		ddlScrumMasters.DataValueField = "UserId"
        ddlScrumMasters.DataBind()

        ddlScrumMasters.Items.Insert(0, New ListItem("Choose a Scrum Master...", "0"))

    End Sub

    Public Sub FillProjectOwnersList(ByVal ddlProjectOwners As DropDownList)

        ddlProjectOwners.Items.Clear()

        ddlProjectOwners.DataSource = _dal.GetProjectOwnersList
        ddlProjectOwners.DataTextField = "UserName"
		ddlProjectOwners.DataValueField = "UserId"
        ddlProjectOwners.DataBind()

        ddlProjectOwners.Items.Insert(0, New ListItem("Choose a Project Owner...", "0"))

    End Sub

    Public Sub FillDevTeamListBox(ByVal lbDevTeam As ListBox)

        lbDevTeam.DataSource = _dal.GetDevTeamList()
        lbDevTeam.DataTextField = "UserName"
        lbDevTeam.DataValueField = "UserID"
        lbDevTeam.DataBind()

    End Sub

    Public Sub FillSubtasksforFeature(ByVal gvSubtasks As GridView, ByVal iFeatureID As Integer)

        gvSubtasks.DataSource = _dal.GetSubtasksForFeature(iFeatureID)
        gvSubtasks.DataBind()

	End Sub

	Public Sub FillSubtasksforFeature(ByVal ddlTasks As DropDownList, ByVal iFeatureID As Integer)

		ddlTasks.DataSource = _dal.GetSubtasksForFeature(iFeatureID)
		ddlTasks.DataTextField = "taskName"
		ddlTasks.DataValueField = "taskID"
		ddlTasks.DataBind()

		ddlTasks.Items.Insert(0, New ListItem("Select subtask...", "0"))

	End Sub

	Public Sub FillFeaturesInSprint(ByVal iSprintId As Integer, ByVal ddlFeaturesInSprint As DropDownList)

		ddlFeaturesInSprint.DataSource = _dal.GetFeaturesInSprint(iSprintId)
		ddlFeaturesInSprint.DataTextField = "featureName"
		ddlFeaturesInSprint.DataValueField = "featureID"
		ddlFeaturesInSprint.DataBind()

		ddlFeaturesInSprint.Items.Insert(0, New ListItem("Choose a feature...", "0"))

	End Sub

	Public Sub FillUnclaimedTasks(ByVal ddlUnclaimedTasks As DropDownList, ByVal iFeatureID As Integer)

		ddlUnclaimedTasks.DataSource = _dal.GetUnclaimedTasks(iFeatureID)
		ddlUnclaimedTasks.DataTextField = "taskName"
		ddlUnclaimedTasks.DataValueField = "taskID"
		ddlUnclaimedTasks.DataBind()

		If ddlUnclaimedTasks.Items.Count > 0 Then
			ddlUnclaimedTasks.Items.Insert(0, New ListItem("Select a subtask...", "0"))
		Else
			ddlUnclaimedTasks.Items.Insert(0, New ListItem("No unclaimed subtasks..", "0"))
		End If

	End Sub

    Public Sub FillActiveSprints(ByVal ddlActiveSprints As DropDownList)

        ddlActiveSprints.Items.Clear()

        ddlActiveSprints.DataSource = _dal.GetActiveSprints
        ddlActiveSprints.DataTextField = "SprintName"
        ddlActiveSprints.DataValueField = "SprintID"
        ddlActiveSprints.DataBind()

        ddlActiveSprints.Items.Insert(0, New ListItem("Choose an Active Sprint...", "0"))

    End Sub

    Public Sub FillFeaturesForSprint(ByVal ddlSprintFeatures As DropDownList, ByVal iSprintID As Integer)

        ddlSprintFeatures.Items.Clear()

        ddlSprintFeatures.DataSource = _dal.GetSprintFeatures(iSprintID)
        ddlSprintFeatures.DataTextField = "FeatureName"
        ddlSprintFeatures.DataValueField = "FeatureID"
        ddlSprintFeatures.DataBind()

        ddlSprintFeatures.Items.Insert(0, New ListItem("Choose a feature...", "0"))

    End Sub

    Public Sub FillSubtasksForFeatureInSprint(ByVal gvSubtasksInSprint As GridView, ByVal iFeatureID As Integer)

        gvSubtasksInSprint.DataSource = _dal.GetSubtasksForFeatureInSprint(iFeatureID)
        gvSubtasksInSprint.DataBind()

	End Sub

	Public Sub FillSprintsForUser(ByVal sUserId As String, ByVal ddlSprints As DropDownList)

		ddlSprints.DataSource = _dal.FillSprintsForUser(sUserId)
		ddlSprints.DataTextField = "SprintName"
		ddlSprints.DataValueField = "SprintID"
		ddlSprints.DataBind()

		ddlSprints.Items.Insert(0, New ListItem("Select a sprint...", 0))

	End Sub

	Public Sub FillTasksForUser(ByVal sUserId As String, ByVal ddlTasks As DropDownList)

		ddlTasks.DataSource = _dal.GetTasksForUser(sUserId)
		ddlTasks.DataTextField = "TaskName"
		ddlTasks.DataValueField = "TaskID"
		ddlTasks.DataBind()

		ddlTasks.Items.Insert(0, New ListItem("Select a task...", 0))

	End Sub

	Public Sub FillStatusList(ByVal iStatusType As Integer, ByVal ddlStatus As DropDownList)
		ddlStatus.DataSource = _dal.GetStatuses(iStatusType)
		ddlStatus.DataTextField = "StatusDesc"
		ddlStatus.DataValueField = "StatusId"
		ddlStatus.DataBind()
	End Sub

	Public Sub FillNewDev(ByVal iTaskId As Integer, ByVal ddlNewDev As DropDownList)
		ddlNewDev.DataSource = _dal.GetAlternateTeamMembers(iTaskId)
		ddlNewDev.DataTextField = "UserName"
		ddlNewDev.DataValueField = "UserId"
		ddlNewDev.DataBind()
	End Sub

End Class
